package cn.zhiwen.springsource;

import cn.zhiwen.entity.ZuulRequestModel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class SpringSource {
    public static void main(String[] args) throws IOException {
        // 包装request的输入流
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\WorkSpace\\LambdaAndStream\\jdk8Practise\\springReslove\\src\\main\\resources\\txt"), "utf-8"));
        // 缓冲字符
        StringBuffer sb = new StringBuffer("");
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line);
        }
        br.close(); // 关闭缓冲流
        String result = sb.toString(); // 转换成字符
        System.out.println(result);
        System.out.println("============");
        JSONObject jsonData = JSONObject.parseObject(result);
        System.out.println(jsonData);

        ZuulRequestModel zuulRequestModel = JSON.parseObject(jsonData.toString(), ZuulRequestModel.class);
        System.out.println(zuulRequestModel);
    }
}
